{{>licenseInfo}}
{{#operations}}/*
 * {{classname}}.h
 *
 * {{description}}
 */

#ifndef {{classname}}_H_
#define {{classname}}_H_

{{{defaultInclude}}}
#include "ApiBase.h"

#include <pistache/http.h>
#include <pistache/router.h>
#include <pistache/http_headers.h>
{{^hasModelImport}}#include <nlohmann/json.hpp>{{/hasModelImport}}
#include <optional>
#include <utility>

{{#imports}}{{{import}}}
{{/imports}}

namespace {{apiNamespace}}
{

class {{declspec}} {{classname}} : public ApiBase {
public:
    explicit {{classname}}(const std::shared_ptr<Pistache::Rest::Router>& rtr);
    ~{{classname}}() override = default;
    void init() override;

    static const std::string base;

private:
    void setupRoutes();

    {{#operation}}
    void {{operationIdSnakeCase}}_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);
    {{/operation}}
    void {{classnameSnakeLowerCase}}_default_handler(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter response);

    /// <summary>
    /// Helper function to handle unexpected Exceptions during Parameter parsing and validation.
    /// May be overridden to return custom error formats. This is called inside a catch block.
    /// Important: When overriding, do not call `throw ex;`, but instead use `throw;`.
    /// </summary>
    virtual void handleParsingException(const std::exception& ex, Pistache::Http::ResponseWriter &response) const noexcept;

    /// <summary>
    /// Helper function to handle unexpected Exceptions during Parameter parsing and validation.
    /// May be overridden to return custom error formats. This is called inside a catch block.
    /// Important: When overriding, do not call `throw ex;`, but instead use `throw;`.
    /// </summary>
    virtual std::pair<Pistache::Http::Code, std::string> handleParsingException(const std::exception& ex) const noexcept;

    /// <summary>
    /// Helper function to handle unexpected Exceptions during processing of the request in handler functions.
    /// May be overridden to return custom error formats. This is called inside a catch block.
    /// Important: When overriding, do not call `throw ex;`, but instead use `throw;`.
    /// </summary>
    virtual void handleOperationException(const std::exception& ex, Pistache::Http::ResponseWriter &response) const noexcept;

    /// <summary>
    /// Helper function to handle unexpected Exceptions during processing of the request in handler functions.
    /// May be overridden to return custom error formats. This is called inside a catch block.
    /// Important: When overriding, do not call `throw ex;`, but instead use `throw;`.
    /// </summary>
    virtual std::pair<Pistache::Http::Code, std::string> handleOperationException(const std::exception& ex) const noexcept;

    {{#operation}}
    /// <summary>
    /// {{summary}}
    /// </summary>
    /// <remarks>
    /// {{notes}}
    /// </remarks>
    {{#vendorExtensions.x-codegen-pistache-is-parsing-supported}}
    {{#allParams}}
    /// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
    {{/allParams}}
    virtual void {{operationIdSnakeCase}}({{#authMethods}}{{#isBasicBasic}}const HttpBasicCredentials &credentials, {{/isBasicBasic}}{{#isBasicBearer}}const HttpBearerToken &accessToken, {{/isBasicBearer}}{{/authMethods}} {{#allParams}}const {{#isModel}}{{^isOptional}}{{modelNamespace}}::{{/isOptional}}{{/isModel}}{{{dataType}}} &{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#hasParams}}, {{/hasParams}}Pistache::Http::ResponseWriter &response) = 0;
    {{/vendorExtensions.x-codegen-pistache-is-parsing-supported}}
    {{^vendorExtensions.x-codegen-pistache-is-parsing-supported}}
    virtual void {{operationIdSnakeCase}}(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response) = 0;
    {{/vendorExtensions.x-codegen-pistache-is-parsing-supported}}
    {{/operation}}

};

} // namespace {{apiNamespace}}

#endif /* {{classname}}_H_ */

{{/operations}}
